/**
 * 
 */
package service;

import dao.SeniorAdminDao;
import dao.SeniorAdminDaoImpl;
import dao.UserDao;
import dao.UserDaoImpl;
import exception.ApplicationException;
import model.Administrator;
import model.User;

/**
 * @ClassName: SystemServiceImpl
 * @Description:
 * @author Hongming Wu
 * @date 2013-12-7
 * 
 */
public class SystemServiceImpl implements SystemService {

	@Override
	public Administrator checkAdmin(String userName, String userPwd) {
		SeniorAdminDao sad = new SeniorAdminDaoImpl();
		Administrator admin = sad.getAdminByName(userName);

		if (!admin.getAdmin_Pwd().equals(userPwd)) {
			throw new ApplicationException("Wrong Password, Please Check!");
		}
		return admin;
	}

	@Override
	public User checkUser(String userName, String userPwd) {
		UserDao ud = new UserDaoImpl();
		User user = ud.getUserByName(userName);
		
		if (!user.getUser_Pwd().equals(userPwd)) {
			throw new ApplicationException("Wrong Password, Please Check!");
		}
		return user;
	}

}
